package org.zkoss.view.converter;

import org.zkoss.model.bean.Company;
import org.zkoss.service.CompanyManager;
import org.zkoss.service.ServiceLocator;
import org.zkoss.zk.ui.Component;
import org.zkoss.zkplus.databind.TypeConverter;

public class HibernateSessionMergeConverter implements TypeConverter {

	private CompanyManager manager = ServiceLocator.getCompanyManager();
	
	public Object coerceToUi(Object data, Component comp) {
		Company company = null;
		if(data instanceof Company) {
			company = manager.findById(((Company) data).getIdcompany());
		}
		return company;
	}

	public Object coerceToBean(Object val, Component comp) {
		return null;
	}

}
